﻿using Microsoft.AspNetCore.SignalR;
using System.Security.Claims;

namespace WebAPI.Hubs
{
    public class NotificationHub : Hub
    {
        // 用户连接时绑定用户ID（需结合身份验证）
        public override async Task OnConnectedAsync()
        {
            var userId = Context.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
            if (userId != null)
                await Groups.AddToGroupAsync(Context.ConnectionId, userId);
            await base.OnConnectedAsync();
        }
    }
}
